# process password & username for scripts that need it

my $username=$query->param(uname) or my $username="username";
my $password=$query->param(pwd) or my $password="password";
my $firsttime=$query->param(firsttime) or my $firsttime=1;

@script=split(/\./,$scriptname);

# do some kind of hashing with the password

open (PASS, register);
while (<PASS>) {
  $line=$_;
  %logins=($line)  # where line is comma separated but probably won't work
}
close (PASS);

print "<html><head><title>Login</title></head><body>"


if ($logins{$username}!=$password) {
  if ($firsttime==0) {
    print "<p>Login failed</p>"
    &form()
    exit
  }
  else {
    &form
  }
}


sub form {
print "<form action=$scriptname method=POST>".
"<input type=text name=username value=$username><br>".
"<input type=password name=password><br>".
"<input type=hidden name=firsttime value=0>".
"<input type=submit name=submit value="log into $script[0]">.
"</form></body></html>"
}

